package nc.hw;

import java.util.Arrays;
import java.util.Comparator;

public class HJ45 {

    private static int pretty(String word) {
        word = word.toLowerCase();
        // 按照字母出现次数排序
        int[] nums = new int[26];
        for (char c : word.toCharArray()) {
            nums[c - 'a'] ++;
        }
        // 事实上，根本不需要获取对应的index，按照次数计数即可
        Arrays.sort(nums);
        int result = 0;
        int pretty = 26;
        for (int i = 25;i >= 0; i --) {
            result += pretty * nums[i];
            pretty --;
        }
        return result;
    }

    public static void main(String[] args) {
        System.out.println(pretty("zhangsan"));
        System.out.println(pretty("lisi"));
    }
}
